<%
layout("/_container.html"){
%>
		<div class="wrap-container">
			<form class="layui-form" style="width: 90%;padding-top: 20px;" action="">
				<input type="hidden" name="id" value="${menu.id!}"/>
				
				<#laytree id="menuSel" name="上级" url="/menu/topMenus" hidden="parentId" hiddenName="id" 
					value="${parent.name!'顶级'}" hiddenValue="${parent.id!0}"/>
				<#input label="菜单名称" name="name" placeholder="请输入菜单名称" value="${menu.name!}" required="false"/>
				<#input label="菜单编号" name="code" placeholder="请输入菜单编号" value="${menu.code!}"/>
				<#input label="权限名称" name="permission" placeholder="请输入权限名称" value="${menu.permission!}"/>
				<#input label="请求地址" name="url" placeholder="请输入请求地址" value="${menu.url!}" required="false"/>
				<#radio label="状态" name="available" left="显示" right="隐藏" leftVal="true" rightVal="false" value="${menu.available!}"/>
				<#radio label="资源类型" name="resourceType" left="菜单" right="按钮" leftVal="menu" rightVal="button" value="${menu.resourceType!}"/>
				
					<div class="layui-form-item">
						<div class="layui-input-block">
							<button class="layui-btn layui-btn-normal" lay-submit lay-filter="formDemo">立即提交</button>
							<button type="reset" class="layui-btn layui-btn-primary">重置</button>
						</div>
					</div>
				</form>
		</div>

		<script>
			layui.use(['form'], function() {
				var form = layui.form();
				form.render();
				//监听提交
				form.on('submit(formDemo)', function(data) {
					try{
						 layui.jquery.post("/menu/save",data.field,function(data){
								index = parent.layer.index;
								if(data){
									parent.refresh();
									parent.dialog.success("操作成功");
								}else
									parent.dialog.error("操作失败,请重试");
							}); 						
					}catch(e){
						console.log(e);						
					}

					return false;
				});
			});
		</script>
<% } %>